/*
 * Moon.cpp
 *
 *  Created on: 23/05/2013
 *      Author: vitor
 */

#include "Moon.h"

Moon::Moon(Sprite* sprite, int hitPoints, Planet* center) :
		Planet(sprite, hitPoints, center->getBox()->getPositionRef()->getX(),
				center->getBox()->getPositionRef()->getY()) {
	this->center = center;
	angle = 0;
	radius = 240;
}

int Moon::update(double dt) {

	int angularSpeed = 1;
	float deslocX;
	float deslocY;

	angle += angularSpeed * dt;

	deslocX = sin(angle) * radius;
	deslocY = cos(angle) * radius;

	this->box.getPositionRef()->setX(
			(center->getBox()->getPositionRef()->getX()) + deslocX
					- (this->sprite->getWidth() / 2));
	this->box.getPositionRef()->setY(
			(center->getBox()->getPositionRef()->getY()) + deslocY
					- (this->sprite->getHeight() / 2));

	return 0;

}
